Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch rustdoc from clean::Stability to rustc_attr::Stability #77817

Merged
merged 3 commits into from
Oct 14, 2020

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Oct 11, 2020

This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on #76998.

  • Remove clean::Stability in favor of rustc_attr::Stability
  • Remove impl Clean for Stability; it's no longer necessary

r? @GuillaumeGomez
cc @petrochenkov

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 11, 2020
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 11, 2020
This gives greater type safety and is less work to maintain on the
rustdoc end.
(Self::Unstable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Equal),
(Self::Stable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Equal),
(Self::Unstable { .. }, Self::Stable { .. }) => Some(cmp::Ordering::Less),
(Self::Stable { .. }, Self::Unstable { .. }) => Some(cmp::Ordering::Greater),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this bit in rustdoc (and remove the PartialOrd impl from StabilityLevel?).
I don't know what rustdoc rendering wants when sorting by stability, but it probably isn't something generally applicable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this can be simplified to mem::discriminant(self).cmp(mem::discriminant(other)).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this can be simplified to mem::discriminant(self).cmp(mem::discriminant(other)).

Does rustc guarantee that the order of the enums matches the order of the discriminants? I thought layout was unspecified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, thanks!

@petrochenkov
Copy link
Contributor

LGTM modulo the ordering bit.

Rustdoc's ordering requirements are probably not relevant to the rest of
the compiler.
@petrochenkov
Copy link
Contributor

r? @petrochenkov @bors r+

@bors
Copy link
Contributor

bors commented Oct 11, 2020

📌 Commit 96b0446 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 11, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Oct 13, 2020
Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`

This gives greater type safety and is less work to maintain on the rustdoc end. It also makes rustdoc more consistent with rustc.
Noticed this while working on rust-lang#76998.

- Remove `clean::Stability` in favor of `rustc_attr::Stability`
- Remove `impl Clean for Stability`; it's no longer necessary

r? @GuillaumeGomez
cc @petrochenkov
This was referenced Oct 13, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 14, 2020
Rollup of 8 pull requests

Successful merges:

 - rust-lang#77765 (Add LLVM flags to limit DWARF version to 2 on BSD)
 - rust-lang#77788 (BTreeMap: fix gdb provider on BTreeMap with ZST keys or values)
 - rust-lang#77795 (Codegen backend interface refactor)
 - rust-lang#77808 (Moved the main `impl` for FnCtxt to its own file.)
 - rust-lang#77817 (Switch rustdoc from `clean::Stability` to `rustc_attr::Stability`)
 - rust-lang#77829 (bootstrap: only use compiler-builtins-c if they exist)
 - rust-lang#77870 (Use intra-doc links for links to module-level docs)
 - rust-lang#77897 (Move `Strip` into a separate rustdoc pass)

Failed merges:

 - rust-lang#77879 (Provide better documentation and help messages for x.py setup)
 - rust-lang#77902 (Include aarch64-pc-windows-msvc in the dist manifests)

r? `@ghost`
@bors bors merged commit 41146c1 into rust-lang:master Oct 14, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 14, 2020
@jyn514 jyn514 deleted the const-since branch February 25, 2023 18:32
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 24, 2023
Sort unstable items last in rustdoc, instead of first

As far as I can tell, this is a bug introduced inadvertently by rust-lang#77817 in Rust 1.49. Older toolchains used to sort unstable items last.

Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`.

Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 24, 2023
Rollup merge of rust-lang#118224 - dtolnay:rustdocsortunstable, r=fmease

Sort unstable items last in rustdoc, instead of first

As far as I can tell, this is a bug introduced inadvertently by rust-lang#77817 in Rust 1.49. Older toolchains used to sort unstable items last.

Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`.

Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants